home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / fmodla13.zip / TALK.ZIP / RS232.DEF < prev    next >
Text File  |  1987-10-18  |  3KB  |  94 lines

  1. DEFINITION MODULE RS232;
  2.  
  3. (* (C) Copyright 1987 Fitted Software Tools. All rights reserved.
  4.  
  5.     This module is part of the example multitasking communications program
  6.     provided with the Fitted Software Tools' Modula-2 development system.
  7.  
  8.     Registered users may use this program as is, or they may modify it to
  9.     suit their needs or as an exercise.
  10.  
  11.     If you develop interesting derivatives of this program and would like
  12.     to share it with others, we encourage you to upload a copy to our BBS.
  13. *)
  14.  
  15. (*
  16.     This module provides buffered, interrupt driven, communications I/O
  17. *)
  18.  
  19. FROM Kernel     IMPORT SignalHeader, LockHeader;
  20.  
  21. VAR RS232Input  :SignalHeader;  (* everytime a character is received *)
  22.                                 (* a Signal is sent to this SignalHeader *)
  23.  
  24.  
  25. (*
  26.     When Init is invoked, a COM port is initialized for communications
  27.     I/O and a process is started to service the interrupts from the COM
  28.     port.
  29.  
  30.     The COM interrupt service routine places the characters received
  31.     in a circular buffer, the size of which is specified when Init
  32.     is called.
  33. *)
  34.  
  35. (*========================================================================*)
  36. (*  Initializing the port.
  37.     Init must be called before issuing I/O to the COM port.
  38. *)
  39.  
  40. PROCEDURE Init( portNumber      :CARDINAL;      (* 1 or 2       *)
  41.                 baudRate        :CARDINAL;      (* 300..38400   *)
  42.                 nStopBits       :CARDINAL;      (* 1 or 2       *)
  43.                 parityEnable    :BOOLEAN;
  44.                 evenParity      :BOOLEAN;
  45.                 charSize        :CARDINAL;      (* 5..8         *)
  46.                 inBufferSize    :CARDINAL;      (* input buffer size *)
  47.                 VAR done        :BOOLEAN        (* success      *)
  48.               );
  49.     (*  Initialize the COM port *)
  50.  
  51.  
  52. PROCEDURE ResetPars( baudRate        :CARDINAL;      (* 300..38400   *)
  53.                      nStopBits       :CARDINAL;      (* 1 or 2       *)
  54.                      parityEnable    :BOOLEAN;
  55.                      evenParity      :BOOLEAN;
  56.                      charSize        :CARDINAL;      (* 5..8         *)
  57.                      VAR done        :BOOLEAN        (* success      *)
  58.                      );
  59.     (* reset the parameters of the active COM port *)
  60.  
  61.  
  62. (*========================================================================*)
  63. (*  Reading and Writing to the COM port:
  64. *)
  65.  
  66. PROCEDURE GetCom( VAR ch :CHAR; VAR received :BOOLEAN );
  67.     (*  IF a character is available for reading THEN
  68.             ch gets the next character,
  69.             received is set to TRUE
  70.         ELSE
  71.             received is set to FALSE
  72.     *)
  73.  
  74. PROCEDURE PutCom( ch :CHAR );
  75.     (*  sends ch to the remote system *)
  76.  
  77.  
  78. (*======================================================================*)
  79. (*  XON / XOFF processing:
  80.     If enabled, the input interrupt service routime will send an XOFF
  81.     to the remote system whenever the input buffer is over 75% full.
  82.     An XON will be sent (if an XOFF was sent) when the input buffer
  83.     is 50% empty.
  84.  
  85.     Unless XON is called, XON / XOFF is not enabled.
  86. *)
  87.  
  88. PROCEDURE XON;
  89.     (* enable xon/xoff processing *)
  90.  
  91. PROCEDURE XOFF;
  92.     (* disable xon/xoff processing *)
  93.  
  94. END RS232.